#include<iostream>
#include <unistd.h>
#include <string>
#include <cstdio>
#include <pthread.h>

using namespace std;
int x = 200;
void show(const string& name)
{
    cout << name << "  PID : " << getpid() << " " <<  x << endl;
}
void* ThreadRun(void* argv)
{
    const string name((char*)argv);
    while(true)
    {
        show(name);
        sleep(1);
    }
    
}
int main()
{
    char name[64];
    pthread_t tid[5];
    for(int i = 0; i< 5;i++)
    {
        snprintf(name,sizeof name,"%s-%d","这是一个线程",i);
        pthread_create(tid+i,nullptr,ThreadRun,(void*)name);
        sleep(1);
    }
    while(true)
    {
        cout << "main thread ,pid : " << getpid() << endl;
        sleep(3);
    }
    return 0;
}